;
;  SYSLIB Module Name:  SZGPIN
;  Author:  Richard Conn
;  SYSLIB Version Number:  2.1
;  Module Version Number:  1.0
;  Module Entry Points:
;	ZGPINS
;  Module External References:
;	ZINIMC		ZINIEXT		ZCPRSET		ZFNINIT
;	MOVEB
;

;
;	This SYSLIB subroutine is used to properly initialize all of
; the ZCPR2-specific routines based on the ZCPR2 Utility Standard
; General-Purpose Installation Format.
;

;
;	The following equates define the relative addresses of
; the Installation Format Variables.
;
	.radix	16	; use base 16 numbers (all numbers in Hex)

base	equ	103	; beginning of variable area
epavail	equ	base	; external path available flag
epadr	equ	base+1	; address of external path

intpath	equ	base+3	; address of beginning of 8-elt internal path

mcavail	equ	base+14	; multiple command line buffer available flag
mcadr	equ	base+15	; address of multiple command line buffer

cindic	equ	base+51	; current user/disk indicator

dmadr	equ	base+52	; default DMA address

mdnames	equ	base+54	; max number of directory names
dnfile	equ	base+55	; name of named directory file

;
;  Internal Buffers for the Init
;
dnfcb:
	ds	0C	; disk name fcb (12 BYTES)

;
;  EXTERNALS
;
	EXT	MOVEB	; COPY ROUTINE
	EXT	ZINIMC	; MULTIPLE COMMAND LINE BUFFER INIT
	EXT	ZINIEXT	; EXTERNAL PATH INIT
	EXT	ZCPRSET	; CURRENT USER/DISK FLAG AND DMA ADDRESS
	EXT	ZFNINIT	; NAMES.DIR AND MAX DIR COUNT INIT

;
;  Beginning of init routine
;
ZGPINS::
	PUSH	H	; SAVE REGS
	PUSH	D
	PUSH	B
	PUSH	PSW

;
;  INIT NAMES.DIR FILE NAME AND MAX NUMBER OF ENTRIES
;
	LXI	H,DNFILE	; SET UP DISK NAME FCB
	LXI	D,DNFCB+1	; FN AND FT COPIED
	MVI	B,0B		; 11 BYTES
	CALL	MOVEB
	XRA	A		; ZERO FIRST BYTE
	STA	DNFCB
	LDA	MDNAMES		; GET NUMBER OF NAMES ALLOWED
	MOV	C,A		; ... IN C
	LXI	H,DNFCB		; INIT NAMES.DIR FILE
	MVI	A,0FF		; SET EVERYTHING
	CALL	ZFNINIT		; DO INIT

;
;  INIT CURRENT USER/DISK INDICATOR AND DMA ADDRESS
;
	LDA	CINDIC		; GET INDICATOR
	LHLD	DMADR		; GET DMA ADDRESS
	CALL	ZCPRSET

;
;  INIT EXTERNAL PATH ADDRESS
;
	LHLD	EPADR		; PREP TO DECLARE EXTERNAL PATH
	LDA	EPADR		; GET FLAG
	ORA	A		; NZ = EXTERNAL PATH OK
	JNZ	ZINI1		; DO INIT
	LXI	H,INTPATH	; PT TO INTERNAL PATH OTHERWISE
ZINI1:
	CALL	ZINIEXT		; INIT EXTERNAL PATH

;
;  INIT MULTIPLE COMMAND LINE BUFFER PTRS
;
	LDA	MCAVAIL		; GET FLAG
	LHLD	MCADR		; GET ADDRESS
	ORA	A		; SET FLAGS (0=NO)
	CNZ	ZINIMC		; INIT MC LINE BUFFER IF DESIRED

	POP	PSW		; RESTORE REGS
	POP	B
	POP	D
	POP	H
	RET

	END
